package com.flying.learning.si.sg;

import com.flying.learning.si.sg.gateways.HelloWorldGateway;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
@Slf4j
public class Application {
    public static void main(String[] args) {
        ApplicationContext ctx = SpringApplication.run(Application.class, args);
        HelloWorldGateway gateway = (HelloWorldGateway) ctx.getBean("helloWorldGateway");
//        gateway.sayHello("John");

        String message = gateway.getHelloMessage("John (get message)");
        log.info(message);

//        Future<String> helloFuture = gateway.getHelloMessageAsync("John (Async!)");

//        try {
//            String helloFutureMsg = helloFuture.get();
//            log.info(helloFutureMsg);
//        } catch (InterruptedException ie) {
//            ie.printStackTrace();
//        } catch (ExecutionException ee) {
//            ee.printStackTrace();
//        }
//        SpringApplication.run(Application.class, args);
    }
}
